package com.zy;

import com.zy.bean.User;
import com.zy.config.ApplicationContext;
import com.zy.controller.UserController;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author LittleDesire
 * @description
 * @date 2022-03-29 周二 16:14
 * @since 17
 */
public class App {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ctx.register(ApplicationContext.class);
        ctx.refresh();
        Object user = ctx.getBean(User.class);
        System.out.println(user);
        UserController bean = ctx.getBean(UserController.class);
        System.out.println(bean);

       /* AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
//        ctx.getEnvironment().setActiveProfiles("dev");
        ctx.getEnvironment().setActiveProfiles("pro");
        ctx.register(ApplicationContext.class);
        ctx.refresh();
        Object ds = ctx.getBean("ds");
//        System.out.println(ds); // DataSource(url=http:dev, name=root, pwd=123
        System.out.println(ds); // DataSource(url=http:pro, name=lili, pwd=456)
        System.out.println(ctx.getBean(UserController.class));*/
    }
}
